import React, {Component} from 'react';
import storageUtil from "../../../utils/storageUtil";
import {List, Avatar, Button} from 'antd';





class MyOrder extends Component {

    state = {
        orders: '',
        oid: ''
    }


    componentDidMount() {
        const uid = storageUtil.getUser().uid
        this.$myAxios.get('/order/showByUid/' + uid).then(res => {
            console.log(res.data)
            this.setState({
                orders: res.data
            })
        })

    }

    render() {
        return (
                    <List
                        itemLayout="horizontal"
                        dataSource={this.state.orders}
                        renderItem={item => (
                            <List.Item>
                                <List.Item.Meta
                                    avatar={<Avatar src="/static/image/order.png"/>}
                                    title={item.theme}
                                    description={"创建时间：" + item.createtime}
                                />
                                <Button
                                    onClick={()=>{
                                        console.log(item)
                                        storageUtil.saveOrder(item)
                                        this.props.history.push("/admin/qa")
                                        console.log(storageUtil.getOrder())
                                    }}
                                    style={{marginLeft: '10px', marginRight: '10px'}}
                                    type="primary"
                                >
                                        详细信息
                                </Button>

                            </List.Item>

                        )}

                    />

        )

    }
}

export default MyOrder;